package com.kpx.app.view;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.kpx.app.R;
import com.kpx.app.bean.BannerBean;
import com.kpx.app.bean.MenuBean;

/**
 * Created by Administrator on 2017/4/6.
 */

public class ViewMainTj extends RelativeLayout {

    private final View view;
    private final Context context;
    private MenuBean b;
    private OnclickBackListener backl;

    public ViewMainTj(Context context) {
        super(context);
        this.context = context;
        view = View.inflate(context, R.layout.view_main_tj, this);
    }

    public void setData(final MenuBean b, final OnclickBackListener backl) {
        this.b = b;
        this.backl = backl;
//        ((TextView) view.findViewById(R.id.txt_tj)).setText(b.getName());
        /**
         * 这里你可以根据框架灵活设置
         */
        Glide.with(context)
                .load(b.getImgs())
                .fitCenter()
                .placeholder(R.drawable.ic_logo)
                .crossFade()
                .into((ImageView) (ImageView) view.findViewById(R.id.img_tj));
        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (backl != null) {
                    backl.toback(b);
                }
            }
        });
    }
    public void setData(String[] s, final OnclickBackListener backl) {
        this.backl = backl;
        ((TextView) view.findViewById(R.id.txt_tj)).setText("更多");
        ((TextView) view.findViewById(R.id.txt_tj2)).setText("查看全部");
        ((TextView) view.findViewById(R.id.txt_tj)).setTextSize(16);
        ((TextView) view.findViewById(R.id.txt_tj2)).setTextSize(13);
        ((TextView) view.findViewById(R.id.txt_tj2)).setVisibility(View.VISIBLE);
        view.findViewById(R.id.img_tj).setBackgroundResource(R.drawable.tg_stoke_shape);

        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (backl != null) {
                    backl.toback(b);
                }
            }
        });
    }

    public interface OnclickBackListener {
        void toback(MenuBean b);
    }
}
